﻿using System.Data;
using LibDBConnect;

namespace LibDataLayer
{
    public static class DalAdv
    {
        private static readonly SqlHelper Cls = new SqlHelper();
        #region[Get-Data]
        public static DataTable GetAdv()
        {
            Cls.CreateNewSqlCommand();
            return Cls.GetData("sp_Adv_Get");
        }
        public static DataTable GetAdvEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Adv_Id", id);
            return Cls.GetData("sp_Adv_Get_Edit");
        }
        public static DataTable GetAdvFillterStatus(int IsActive)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("IsActive", IsActive);
            return Cls.GetData("sp_Adv_Get_FillterStatus");
        }
        public static DataTable GetAdvFillterPosition(string Position)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Position", Position);
            return Cls.GetData("sp_Adv_Get_FillterPosition");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(DTOAdv obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Titile", obj.Titile);
            Cls.AddParameter("Img", obj.Img);
            Cls.AddParameter("Url", obj.Url);
            Cls.AddParameter("Short", obj.Short);
            Cls.AddParameter("Position", obj.Position);
            Cls.AddParameter("IsActive", obj.IsActive);
            Cls.AddParameter("Num", obj.Num);
            return Cls.ExecuteNonQuery("sp_Adv_Get_Insert");
        }
        public static bool Update(DTOAdv obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Adv_Id", obj.Adv_Id);
            Cls.AddParameter("Titile", obj.Titile);
            Cls.AddParameter("Img", obj.Img);
            Cls.AddParameter("Url", obj.Url);
            Cls.AddParameter("Short", obj.Short);
            Cls.AddParameter("Position", obj.Position);
            return Cls.ExecuteNonQuery("sp_Adv_Get_Update");
        }
        public static bool Delete(DTOAdv obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Adv_Id", obj.Adv_Id);
            return Cls.ExecuteNonQuery("sp_Adv_Get_Delete");
        }
        public static bool UpdateNum(DTOAdv obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Num", obj.Num);
            Cls.AddParameter("Adv_Id", obj.Adv_Id);
            return Cls.ExecuteNonQuery("sp_Adv_Update_Num");
        }
        public static bool UpdateCheck(DTOAdv obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Adv_Id", obj.Adv_Id);
            Cls.AddParameter("IsActive", obj.IsActive);
            return Cls.ExecuteNonQuery("sp_Adv_Update_Check");
        }
        #endregion

        #region[Get-Data-HomePage]
        public static DataTable GeAdvHomePage(string Position)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("Position", Position);
            return Cls.GetData("sp_Adv_Get_HomePage");
        }
        #endregion
    }
    public class DTOAdv
    {
        public int Adv_Id { get; set; }
        public string Titile { get; set; }
        public string Img { get; set; }
        public string Url { get; set; }
        public string Short { get; set; }
        public string Position { get; set; }
        public bool IsActive { get; set; }
        public int Num { get; set; }
        public int Msg { get; set; }

    }
}
